package zju.xmsx.acm.search.back.dto;

import org.apache.lucene.search.TotalHits;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;

import zju.xmsx.acm.search.back.dto.SearchResult;

public class SearchResults {
    public float maxScore;
    public TotalHits totalHits;
    public SearchResult[] hits;

    public SearchResults(float maxScore, TotalHits totalHits, SearchResult[] hits) {
        this.maxScore = maxScore;
        this.totalHits = totalHits;
        this.hits = hits;
    }

    public SearchResults(SearchHits param) {
        this.maxScore = param.getMaxScore();
        this.totalHits = param.getTotalHits();
        hits = new SearchResult[param.getHits().length];
        int i = 0;
        for (SearchHit t : param) {
            hits[i++] = new SearchResult(t);
        }
    }
}
